cmake_minimum_required(VERSION 3.5)
project(basic_sprayer)

# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# 添加第三方库
set(INC_DIR /usr/local/include)
set(LINK_DIR /usr/local/lib)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

# set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include_directories($(INC_DIR))
link_directories($(LINK_DIR))

link_libraries(modbus)
link_libraries(iio)
# link_libraries(DSPFilters)


# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(basic_sprayer_interfaces REQUIRED)
find_package(sensor_msgs REQUIRED)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # uncomment the line when a copyright and license is not present in all source files
  #set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # uncomment the line when this package is not in a git repo
  #set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

# 这个不要了  Deprecated
#add_executable(sprayer src/main.cpp src/bsp_gps.cpp)
#ament_target_dependencies(sprayer rclcpp basic_sprayer_interfaces)         # CHANGE
#target_link_libraries(sprayer modbus)

# #电池的节点
# add_executable(voltage_node src/battery.cpp )
# ament_target_dependencies(voltage_node rclcpp basic_sprayer_interfaces sensor_msgs)         # CHANGE
# target_link_libraries(voltage_node modbus)

# #差分GPS的节点
#add_executable(dgps_node src/dgps.cpp )
#ament_target_dependencies(dgps_node rclcpp basic_sprayer_interfaces sensor_msgs)         # CHANGE
#target_link_libraries(voltage_node modbus)

# add_executable(sprayer_node src/base_control.cpp )
# ament_target_dependencies(sprayer_node rclcpp basic_sprayer_interfaces)         # CHANGE
# target_link_libraries(sprayer_node modbus)

# install(TARGETS
#   voltage_node
#   dgps_node
#   sprayer_node
#   DESTINATION lib/${PROJECT_NAME})

find_package(Qt5 REQUIRED COMPONENTS Core SerialPort )

# Adc 的节点 角度adc数据的获取  数据
add_executable(angleadc src/adc.cpp)
ament_target_dependencies(angleadc rclcpp basic_sprayer_interfaces)         # CHANGE
target_link_libraries(angleadc iio)

add_executable(mpu6050 src/mpu6050.cpp)
ament_target_dependencies(mpu6050 rclcpp basic_sprayer_interfaces)         # CHANGE
target_link_libraries(mpu6050 iio)

add_executable(driver src/driver.cpp)
ament_target_dependencies(driver rclcpp basic_sprayer_interfaces)         # CHANGE
target_link_libraries(driver modbus)

# add_executable(humancmd src/human_modbus.cpp)
# ament_target_dependencies(humancmd rclcpp basic_sprayer_interfaces)         # CHANGE
# target_link_libraries(humancmd modbus)

add_executable(crsf_joysticks src/crsf_joysticks.cpp)
ament_target_dependencies(crsf_joysticks rclcpp basic_sprayer_interfaces) 
target_link_libraries(crsf_joysticks Qt5::SerialPort Qt5::Core)

#更改使用的文件
add_executable(kinematics src/kinematics2.cpp)
ament_target_dependencies(kinematics rclcpp basic_sprayer_interfaces)         # CHANGE
# target_link_libraries(kinematics modbus)
add_executable(record src/record.cpp)
ament_target_dependencies(record rclcpp basic_sprayer_interfaces sensor_msgs)         # CHANGE

#GPS文件获取位置信息
add_executable(dgps src/dgps.cpp)
ament_target_dependencies(dgps rclcpp basic_sprayer_interfaces)

#转换后的ECEF坐标信息
add_executable(ecef src/coortransform.cpp)
ament_target_dependencies(ecef rclcpp basic_sprayer_interfaces)



#rosidl_generate_interfaces(${PROJECT_NAME}
#        "msg/NavStaDP.msg"
#)


install(TARGETS
  angleadc
  mpu6050
  driver
  crsf_joysticks
  kinematics
  record
  dgps
  ecef
  DESTINATION lib/${PROJECT_NAME})

install(DIRECTORY
  launch
  DESTINATION share/${PROJECT_NAME})

ament_package()
